import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';

/////// ToggleWidgetDemo

class ToggleWidgetDemoApp extends StatelessWidget {
	// This widget is the root of your application.
	@override
	Widget build(BuildContext context) {
		return MaterialApp(
			title: 'Sample App',
			theme: ThemeData(
				primaryColor: Colors.blue,
			),
			home: ToggleWidgetDemo(),
		);
	}
}

class ToggleWidgetDemo extends StatefulWidget {
	ToggleWidgetDemo({Key key}) : super(key: key);

	@override
	_ToggleWidgetDemoState createState() =>
		_ToggleWidgetDemoState();
}

class _ToggleWidgetDemoState extends State<ToggleWidgetDemo> {
	// Default value for toggle
	bool toggle = true;

	void _toggle() {
		setState(() {
			toggle = !toggle;
		});
	}

	_getToggleChild() {
		if (toggle) {
			return Text('Toggle One');
		} else {
			return CupertinoButton(
				onPressed: () {},
				child: Text('Toggle Two'),
			);
		}
	}

	@override
	Widget build(BuildContext context) {
		return Scaffold(
			appBar: AppBar(
				title: Text("Sample App"),
			),
			body: Center(
				child: _getToggleChild(),
			),
			floatingActionButton: FloatingActionButton(
				onPressed: _toggle,
				tooltip: 'Update Text',
				child: Icon(Icons.update),
			),
		);
	}
}
